package com.itheima.stock.face.impl;

import com.itheima.stock.common.domian.UserAddDomain;
import com.itheima.stock.face.StockCacheFace;
import com.itheima.stock.mapper.StockBusinessMapper;
import com.itheima.stock.pojo.SysPermission;
import com.itheima.stock.pojo.SysUser;
import com.itheima.stock.secuity.service.LoginUserDetailService;
import com.itheima.stock.service.UserService;
import com.itheima.stock.stocktimertesk.StockTimerTaskService;
import com.itheima.stock.stocktimertesk.impl.StockTimerTaskServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author: siwukun
 * @date: 2022/06/16
 * @description:
 */
@Component
@CacheConfig(cacheNames = "stock")
public class StockCacheFaceImpl implements StockCacheFace {


    @Autowired
    private StockTimerTaskServiceImpl service;



    /**
     * 缓存所有A股code集合
     * key---->stock:getAShareStockCodes
     * 缓存预热：
     *
     * @return
     */
    @Cacheable(key = "#root.method.getName()",unless = "#result==null")
    @Override
    public List<String> getAShareStockCodes() {
        return service.getStockRtIndex();
    }

    /**
     * 缓存清除
     * 用户信息修改时缓存清除
     * @param code
     */
    @CacheEvict
    @Override
    public void removeById(String code) {
    }

}
